//
//  HomeTitleTVCell.m
//  Home
//
//  Created by 曹连华 on 2019/6/20.
//  Copyright © 2019 曹连华. All rights reserved.
//

#import "HomeTitleTVCell.h"
#import "HomeTitleTVCellModel.h"
#import <Masonry/Masonry.h>
@interface HomeTitleTVCell ()

@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UIButton *arrowBtn;

@end

@implementation HomeTitleTVCell
- (UILabel *)titleLabel {
    if (!_titleLabel) {
        _titleLabel = [[UILabel alloc]init];
        _titleLabel.textColor = [UIColor blackColor];
    }
    return _titleLabel;
}
- (UIButton *)arrowBtn {
    if (!_arrowBtn) {
        _arrowBtn = [[UIButton alloc]init];
        [_arrowBtn setBackgroundImage:[UIImage imageNamed:@"arrow_right_gary"] forState:UIControlStateNormal];
        [_arrowBtn addTarget:self action:@selector(arrowBtnAction:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _arrowBtn;
}
- (void)initUI {
    [self setBorderColor:hex(0xCBCBCB)];
    [self setBorderWidth:1];
    [self setBorderOption:BorderOptionBottom];
    [self setBorderInsets:UIEdgeInsetsMake(0, 15, 0, 0)];
    
    [self.contentView addSubview:self.titleLabel];
    [self.contentView addSubview:self.arrowBtn];
    
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.mas_equalTo(15);
        make.top.bottom.mas_equalTo(0);
        make.right.mas_equalTo(self.arrowBtn.mas_left).mas_equalTo(0);
    }];
    
    [self.arrowBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(10);
        make.bottom.mas_equalTo(-15);
        make.trailing.mas_equalTo(-15);
    }];
}

- (void)updateTVCCellWithRowModel:(HomeTitleTVCellModel *)rowModel atIndexPath:(NSIndexPath *)indexPath {
    self.titleLabel.text = rowModel.title;
}

- (void)arrowBtnAction:(UIButton *)btn {
    
}
@end
